package com.sinopec.siam.provisioning.filter;

import com.sinopec.siam.apache.log4j.Logger;
import com.sinopec.siam.provisioning.handle.SimpleProvisioningEventListener;
import com.sinopec.siam.provisioning.timer.ProvisioningEventSubscriberTimer;
import weaver.general.BaseBean;

import javax.servlet.*;
import java.io.IOException;

public class InitFilter implements Filter{
	/** Class logger. */
    private final Logger log = Logger.getLogger(InitFilter.class);
	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub
		BaseBean bs = new BaseBean();
		log.info("================>[Filter]准备开始接收消息");
		bs.writeLog("================>[Filter]准备开始接收消息");
		ProvisioningEventSubscriberTimer provisioningEventSubscriberTimer=ProvisioningEventSubscriberTimer.getInstance(new SimpleProvisioningEventListener());
		try{
			provisioningEventSubscriberTimer.start();
			log.info("================>[Filter]自动开始接收消息.");
			bs.writeLog("================>[Filter]自动开始接收消息.");
		}catch(IllegalThreadStateException e){
		}
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		// TODO Auto-generated method stub
		
	}

	public void destroy() {
		// TODO Auto-generated method stub
		
	}

}
